home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / windowtc.arc / QBENCH10.C < prev    next >
Text File  |  1987-06-20  |  12KB  |  393 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <dos.h>
  4. #include <conio.h>
  5. #include <w1.h>
  6. #include <windprot.h>
  7.  
  8. /*==============================================================================*/
  9. /*  Qbench.c - produces a 'Screens/second' table for Q screen utilities         */
  10. /*                                                                              */
  11. /*  VERSION: 1.0                                                                */
  12. /*  AUTHOR:  (C) 1987 Michael G. Mlachak  (TURBO-C) version                     */
  13. /*           (C) 86,87 James H. leMay (Turbo Pascal) version                    */
  14. /*                                                                              */
  15. /*  DATE: 6-2-1987                                                              */
  16. /*  LIABILITY: Author assumes no reliabilty for misuse                          */
  17. /*  COMMENTS:  Released under the teamware concept. (see other DOC FILES).      */
  18. /*  I'm not trying to support this program, so don't expect it to be perfect.   */
  19. /*  It will just give you a good feel for speed.  The time is adjusted for      */
  20. /*  an average 8 second test for each condition - total of 6 minutes.  For more */
  21. /*  accurate results, change TESTTIME = 16. I would appreciate anyone providing */
  22. /*  me the results on their machine as a disk file including processor number,  */
  23. /*  processor Mhz and Video card.                                               */
  24. /*==============================================================================*/
  25.  
  26. typedef enum {  nowait,wait } WAITS;
  27. typedef enum {  attr,noattr } ATTRS;
  28. typedef enum {  start,stop } STARTSTOP;
  29. typedef char str80[80];
  30.  
  31.   #define PROCS        11
  32.   #define TESTTIME     8  /*  TestTime in seconds for each case.  8 gives +/- 1%  */
  33.   #define HIDECURSOR   8192
  34.   #define CAPS         83
  35.   #define SMALLS       115
  36.   #define CAPD         68
  37.   #define SMALLD       100
  38.   #define FALSE        0
  39.   #define TRUE         1
  40.  
  41.   extern qinit(void);
  42.   void timer(STARTSTOP);
  43.   void checktime(void);
  44.   void allprocs(int);
  45.   void transproc(int);
  46.   void exallproc(ATTRS,int,int);
  47.   void extransproc(ATTRS,int,int);
  48.   void readkb(int *);
  49.   void getkey(void);
  50.   int midword(void);
  51.   int lobyte(void);
  52.  
  53.   int          attrib, count, screens, waitscreens, nowaitscreens, oldcursor;
  54.   int          row, col, rows, cols, procnumber;
  55.   double       scrpersec [PROCS][wait+1][noattr+1];
  56.   double       t1, t2, elapsedtime;
  57.  
  58.   str80        strng;
  59.   WAITS        w;
  60.   ATTRS        a;
  61.   char         scrarray[4000];
  62.   FILE         *fcb;
  63.   int          todisk;
  64.   int          key;
  65.  
  66.    static str80 names[PROCS] = {
  67.       " qwritelv    ",
  68.       " qwritev     ",
  69.       " qwrite      ",
  70.       " qwritec     ",
  71.       " qwritecv    ",
  72.       " qfillc      ",
  73.       " qfill       ",
  74.       " qattr       ",
  75.       " qattrc      ",
  76.       " qstore      ",
  77.       " qrestore    "};
  78.  
  79.  
  80. void main(void)
  81. {
  82.   qinit();
  83.   oldcursor = cursorchange(HIDECURSOR);
  84.   gotorc(1,1);
  85.   qfill(1, 1, 25, 80, 14, ' ');
  86.   qwritec(1,1,80,14,"SCREENS / SECOND table for Q Screen Utilities (TURBO-C).");
  87.   qwritec(2,1,80,14,"(C) COPYRIGHT 1987 Michael G. Mlachak");
  88.   qwritec(3,1,80,14,"(Original TEAMWARE concept (C) 86,87 James H. LeMay");
  89.   qwritec(8, 1, 80, 14, "Data to Screen or Disk[S/D]?");
  90.   gotorc(1, 29);
  91.   getkey();
  92.   qwritec(12, 1, 80, 14, "Don't worry about snow if you have CGA.");
  93.   qwritec(13, 1, 80, 14, "It's testing as if you had an EGA.");
  94.   sleep(3);
  95.  
  96.   for (procnumber = 0; procnumber <= PROCS-1; procnumber++)
  97.      for (w = nowait; w <= wait; w++)
  98.         for (a = attr; a <= noattr; a++)
  99.             scrpersec[procnumber][w][a] = (double)0.0;
  100.   qwait = FALSE;
  101.   w = nowait;
  102.   screens = 600; /*  First guess for screens  */
  103.   checktime();
  104.  
  105.   nowaitscreens = screens;
  106.   exallproc(attr, nowaitscreens, 14);
  107.   extransproc(attr, nowaitscreens, 14);
  108.   qattr(1, 1, 25, 80, 7);
  109.   exallproc(noattr, nowaitscreens, -1);
  110.  
  111.   if ((unsigned)qseg !=0xB000) {
  112.     qwait = TRUE;
  113.     w = wait;
  114.     screens = 90; /*  First guess for screens  */
  115.     checktime();
  116.     waitscreens = screens;
  117.     exallproc(attr, waitscreens, 14);
  118.     extransproc(attr, waitscreens, 14);
  119.     qattr(1, 1, 25, 80, 7);
  120.     exallproc(noattr, waitscreens, -1);
  121.   }
  122.  
  123.   qfill(1, 1, 25, 80, 14, ' ');
  124.   if (todisk) {
  125.      fcb = fopen("QBENCH.DTA","w+");
  126.   }
  127.   else
  128.      fcb = stdout;
  129.   gotorc(1, 1);
  130.   fprintf(fcb,"S C R E E N S / S E C O N D\n");
  131.   fprintf(fcb,"             Chng\n");
  132.   fprintf(fcb,"Function     Attr EGA    CGA\n");
  133.   fprintf(fcb,"--------     ---- -----------\n");
  134.   for (procnumber = 0; procnumber <= 6; procnumber++)
  135.      for (a = attr; a <= noattr; a++) {
  136.          if (a == attr)
  137.             fprintf(fcb,"%s",names[procnumber]);
  138.          else
  139.             fprintf(fcb,"             ");
  140.          if (a == attr)
  141.             fprintf(fcb,"Yes  ");
  142.          else
  143.             fprintf(fcb,"No   ");
  144.          fprintf(fcb,"%5.1f",scrpersec[procnumber][nowait][a]);
  145.          fprintf(fcb,"%6.1f\n",scrpersec[procnumber][wait][a]);
  146.      }
  147.      for (procnumber = 7; procnumber <= 10; procnumber++)  {
  148.         fprintf(fcb,"%s",names[procnumber]);
  149.         if (procnumber < 9)
  150.            fprintf(fcb,"Yes  ");
  151.         else
  152.            fprintf(fcb,"N/A  ");
  153.         fprintf(fcb,"%5.1f",scrpersec[procnumber][nowait][attr]);
  154.         fprintf(fcb,"%6.1f\n",scrpersec[procnumber][wait][attr]);
  155.      }
  156.      gotorc(24, 1);
  157.      fprintf(fcb,"waitscreens= %d\n",waitscreens);
  158.      fprintf(fcb,"nowaitscreens= %d\n",nowaitscreens);
  159.      if (todisk) {
  160.         fclose(fcb);
  161.         qwritec(3,1,80,14,"(Data has been written to QBENCH.DTA)");
  162.      }
  163.      gotorc(24, 1);
  164.      oldcursor = cursorchange(oldcursor);
  165. }  /* main */
  166.  
  167. void         timer(ss)
  168. STARTSTOP    ss;
  169. {
  170.    switch (ss) {
  171.  
  172.       case start:
  173.                  t1 = (midword() * 256.0) + lobyte();
  174.                  elapsedtime = 0.0;
  175.       break;
  176.  
  177.       case stop:
  178.                 t2 = (midword() * 256.0) + lobyte();
  179.                 if (t2 < t1)
  180.                    t2 = t2 + 1573040.0;           /*  max 1,573,040 tics/day  */
  181.                 elapsedtime = (t2 - t1) / 18.206481934;  /* units of secs.. */
  182.       break;
  183.    } /* of switch */
  184. } /* of timer */
  185.  
  186. void         checktime()
  187. {
  188.   strcpy(strng, "TimerTest ");
  189.   for (col = 1; col <= 3; col++)
  190.      strcpy(strng, strcat(strng, strng));
  191.   qfill(1, 1, 25, 80, 14, ' ');
  192.   timer(start);
  193.  
  194.   for (count = 1; count <= screens; count++)
  195.      for (row = 1; row <= 25; row++)
  196.         qwritev(row, 1, 14, strng);
  197.   timer(stop);
  198.   screens = (int)((screens * TESTTIME) / elapsedtime);
  199. }  /* checktime */
  200.  
  201. void         allprocs(procnumber)
  202. int          procnumber;
  203. {
  204.     switch (procnumber) {
  205.  
  206.        case 0:
  207.           timer(start);
  208.           for (count = 1; count <= screens; count++)
  209.              for (row = 1; row <= 25; row++)
  210.                 qwritelv(row, 1, attrib, 80, strng);
  211.           timer(stop);
  212.        break;
  213.  
  214.        case 1:  
  215.           timer(start); 
  216.           for (count = 1; count <= screens; count++)
  217.           for (row = 1; row <= 25; row++) 
  218.              qwritev(row, 1, attrib, strng);
  219.           timer(stop); 
  220.        break;
  221.  
  222.        case 2:
  223.            timer(start);
  224.            for (count = 1; count <= screens; count++)
  225.               for (row = 1; row <= 25; row++)
  226.                  qwrite(row, 1, attrib, strng);
  227.            timer(stop);
  228.        break;
  229.  
  230.        case 3:
  231.           timer(start);
  232.           for (count = 1; count <= screens; count++)
  233.              for (row = 1; row <= 25; row++)
  234.                 qwritec(row, 1, 80, attrib, strng);
  235.           timer(stop);
  236.        break;
  237.  
  238.        case 4: 
  239.           timer(start); 
  240.           for (count = 1; count <= screens; count++)
  241.              for (row = 1; row <= 25; row++) 
  242.                 qwritecv(row, 1, 80, attrib, strng);
  243.           timer(stop); 
  244.        break; 
  245.  
  246.        case 5:
  247.           timer(start);
  248.           for (count = 1; count <= screens; count++)
  249.              qfillc(1, 1, 80, 25, 80, attrib, 'C');
  250.           timer(stop); 
  251.        break; 
  252.   
  253.        case 6: 
  254.           timer(start);
  255.           for (count = 1; count <= screens; count++)
  256.              qfill(1, 1, 25, 80, attrib, 'F'); 
  257.           timer(stop);
  258.        break;
  259.     } /*  switch procnumber */
  260.     if (attrib >= 0)  {
  261.         switch (procnumber) {
  262.   
  263.            case 7: 
  264.               qfill(1, 1, 25, 80, attrib, 'a'); 
  265.               timer(start); 
  266.               for (count = 1; count <= screens; count++)
  267.                  qattr(1, 1, 25, 80, attrib); 
  268.               timer(stop); 
  269.            break;
  270.  
  271.            case 8:
  272.               qfill(1, 1, 25, 80, attrib, 'c');
  273.               timer(start);
  274.               for (count = 1; count <= screens; count++)
  275.               qattrc(1, 1, 80, 25, 80, attrib);
  276.               timer(stop);
  277.            break;
  278.         } /*  switch procnumber  */
  279.     } /* attrib >=0 */
  280.     if (elapsedtime != (double)0.0) {
  281.        scrpersec[procnumber][w][a] = (double)screens / elapsedtime;
  282.     }
  283. }  /* allprocs */
  284.  
  285. void         transproc(procnumber)
  286. int         procnumber;
  287. {
  288.     for (row = 1; row <= 25; row++)
  289.        qwritev(row, 1, attrib, strng);
  290.     switch (procnumber) {
  291.  
  292.        case 9:
  293.           timer(start);
  294.           for (count = 1; count <= screens; count++)
  295.              qstore(1, 1, 25, 80, scrarray);
  296.           timer(stop);
  297.        break;
  298.  
  299.        case 10:
  300.           qstore(1, 1, 25, 80, scrarray);
  301.           timer(start);
  302.           for (count = 1; count <= screens; count++)
  303.              qrestore(1, 1, 25, 80, scrarray);
  304.           timer(stop);
  305.        break;
  306.     } /*  switch procnumber */
  307.     if (elapsedtime != (double)0.0)  {
  308.        scrpersec[procnumber][w][a] = (double)screens / elapsedtime;
  309.  
  310.     }
  311. }  /* transproc */
  312.  
  313. void         exallproc(at, scrs, att)
  314. ATTRS        at; 
  315. int          scrs;
  316. int          att;
  317. {
  318.   static char temp_array[60];
  319.  
  320.   a = at;
  321.   screens = scrs;
  322.   attrib = att; 
  323.   for (procnumber = 0; procnumber <= 8; procnumber++) {
  324.     strcpy(strng, names[procnumber]);
  325.     if (w == wait) 
  326.        strcpy(strng, strcat(strng, " Wait    ")); 
  327.     else
  328.        strcpy(strng, strcat(strng, " No Wait ")); 
  329.     if (a == attr)
  330.        strcpy(strng, strcat(strng, " w/Attr  "));
  331.     else
  332.        strcpy(strng, strcat(strng, " No Attr "));
  333.     memset(temp_array,(char)procnumber + 49,59);
  334.     strncat(strng,temp_array,(80-strlen(strng)));
  335.     allprocs(procnumber); 
  336.   } 
  337. } /* exallproc */
  338.  
  339. void         extransproc(at, scrs, att) 
  340. ATTRS        at; 
  341. int          scrs;
  342. int          att; 
  343.   static char temp_array[60];
  344.  
  345.   a = at;
  346.   screens = scrs; 
  347.   attrib = att; 
  348.   for (procnumber = 9; procnumber <= 10; procnumber++) {
  349.     strcpy(strng, names[procnumber]); 
  350.     if (w == wait)
  351.        strcpy(strng, strcat(strng, " Wait    ")); 
  352.     else
  353.        strcpy(strng, strcat(strng, " No Wait ")); 
  354.     strcpy(strng, strcat(strng, " w/Attr  ")); 
  355.     memset(temp_array,(char)procnumber + 49,59);
  356.     strncat(strng,temp_array,(80-strlen(strng)));
  357.     transproc(procnumber);
  358.   }
  359. } /* extransproc */
  360.  
  361. int midword(void)
  362. {
  363.    return(peek(0x00,0x046D));
  364. }
  365.  
  366. int lobyte(void)
  367. {
  368.   return(peek(0x00,0x046C));
  369. }
  370.  
  371. void        readkb(key)
  372. int         *key; 
  373.  
  374.   int t_key;
  375.  
  376.   t_key = getch();
  377.   if (t_key ==0)     /* extended character hit */
  378.      t_key = getch();
  379.    *key = t_key;
  380. } /* readkb() */
  381.  
  382. void         getkey(void) 
  383.   do { 
  384.      readkb(&key);
  385.   }  while (!((key == CAPS) || (key == CAPD) || (key == SMALLD)
  386.               || (key == SMALLS)));
  387.   todisk = ((key == CAPD) || (key == SMALLD));
  388. }  /* getkey() */
  389.  
  390.